﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Splitting
{
    public class Dungeon
    {
        private Node rootNode = new Node();

        private int size = 256;

        public Dungeon(int size)
        {
            this.size = size;
        }

        public void SplitLeafs()
        {
            SplitNode(rootNode);
        }

        private void SplitNode(Node node)
        {
            if (node.IsLeaf)
                node.Sprout();
            else
            {
                SplitNode(node.Left);
                SplitNode(node.Right);
            }
        }

        private void VisitNode(Node node, bool leafOnly)
        {
            if (node.IsLeaf || !leafOnly)
                node.Report();
            if (node.Left != null)
                VisitNode(node.Left, leafOnly);
            if (node.Right != null)
                VisitNode(node.Right, leafOnly);
        }

    }
}
